package ExecutorService;

import org.junit.Test;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class ExecutorServiceDemo {


    @Test
    public void test() {

        ExecutorService threadPool = Executors.newFixedThreadPool(2);

        Future<Boolean> future = threadPool.submit(new Callable() {

            @Override
            public Object call() throws Exception {
                System.out.println("1");
                return null;
            }

        });
    }


    @Test
    public void test2() {

        ExecutorService executorService = Executors.newFixedThreadPool(10);

        executorService.execute(new Runnable() {
            public void run() {
                System.out.println("Asynchronous task");
            }
        });
        executorService.shutdown();
    }

}
